package com.caltco.cargo.ops.common.base;

import cn.hutool.core.collection.CollectionUtil;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @program: agilefast-framework
 * @description: 暂存查询列的list组装对象
 * @author: yehao
 * @create: 2022-12-08 15:29
 **/

@Getter
@Setter
public class SelectBuilder implements Serializable {
    private static final long serialVersionUID = -1536422416594422874L;

    private List<String> parts;

    public SelectBuilder() {
        this.parts = new ArrayList<>();
    }

    public void toEmpty() {
        parts.clear();
    }

    /**
     * 置 null
     *
     * @since 3.3.1
     */
    public void toNull() {
        parts = null;
    }

    public String getStringValue(){
        if (CollectionUtil.isNotEmpty(parts)) {
            return String.join(",", parts);
        }else {
            return null;
        }
    }

}

